//
//  Extension+NSAttributedString.swift
//  XMWeimo
//
//  Created by ios001 on 16/7/31.
//  Copyright © 2016年 itcast. All rights reserved.
//

import UIKit

extension NSAttributedString {
    
    // 遍历构造函数
    convenience init(emoticon: XMEmoticon, y: CGFloat, lingHeight: CGFloat) {
        // 文本附件
        let att = XMTextAttachment()
        // 赋值
        att.emoticon = emoticon
        // 设置image
        att.image = UIImage.getEmoticonImage(emoticon.path)
        // 设置bounds
        att.bounds = CGRect(x: 0, y: y, width: lingHeight, height: lingHeight)
        self.init(attachment: att)
    }
}
